package com.aceslideshows.common.dao.model;

public abstract class AbstractBaseModel implements SystemEntity
{

    public AbstractBaseModel()
    {

    }

    public abstract long getId();

    public abstract void setId(long id);

    @Override
    public boolean equals(Object obj)
    {
        long id = getId();
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        if (id == NO_ID)
            return false;
        final AbstractBaseModel other = (AbstractBaseModel) obj;
        return (id == other.getId());
    }

    @Override
    public int hashCode()
    {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + (int) getId();

        // Use the Class object to give uniqueness to inheriting classes so they
        // don't have to override the hashcode method.
        result = PRIME * result + (getClass().hashCode());
        return result;
    }

    @Override
    public String toString()
    {

        return new StringBuffer(getClass().getName()).append(" id: ").append(
                getId()).toString();
    }

}
